<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增项目跟踪')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-project-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">项目号：</label>
                <div class="col-sm-8">
                    <input name="projectNo" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">项目负责人：</label>
                <div class="col-sm-8">
                    <input name="projectManager" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">尾款情况：</label>
                <div class="col-sm-8">
                    <input name="paymentStatus" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">预计到货时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="expectedArrivalDate" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">实际到货时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="actualArrivalDate" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="remarks" class="form-control"></textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">创建时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="createdAt" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">更新时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="updatedAt" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "ds/project"
        $("#form-project-add").validate({
            focusCleanup: true,
            rules: {
                projectNo: {
                    required: true,
                    remote: {
                        url: prefix + "/checkProjectNoUnique",
                        type: "post",
                        dataType: "json",
                        data: {
                            "projectNo": function() {
                                return $.trim($("#form-project-add input[name='projectNo']").val());
                            }
                        },
                        dataFilter: function(data, type) {
                            var result = $.parseJSON(data);
                            return result.code === 0 && result.data === true;
                        }
                    }
                }
            },
            messages: {
                projectNo: {
                    required: "项目号不能为空",
                    remote: "项目号已存在"
                }
            }
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-project-add').serialize());
            }
        }

        $("input[name='expectedArrivalDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='actualArrivalDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='createdAt']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='updatedAt']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
    </script>
</body>
</html>